<?php
namespace app\api\controller\yop;

use customtool\Utils;

class Daifu extends Base {
    public function index() {
        date_default_timezone_set('Asia/Shanghai');
        $orderId = 'DF' . date('YmdHis', time()) . rand(10, 99);
        $batchNo =  time(). rand(10000, 99999);
        $this->assign('orderId', $orderId);
        $this->assign('batchNo', $batchNo);
        return $this->fetch();
    }
    
    public function send() {
        $data = input('post.');
        $data['merchant_id'] =  $this->C('merchantId');
        $data['signature'] = apiChangyuanSign($data, $this->C('md5key'));  // 创建签名
        $result = Utils::curl($this->C('daifuUrl'), $data);
        return $result;
    }
    
    /*
     * 余额查询主页
     */
    public function yue() {
        return $this->fetch();
    }
    
    public function sendYuE() {
        $data = input('post.');
        $data['signature'] = apiChangyuanSign($data, $this->C('md5key'));  // 创建签名
        $result = Utils::curl($this->C('daifuYuEUrl'), $data);
        return $result;
    }
    
    /*
     * 代付订单查询主页
     */
    public function query() {
        return $this->fetch();
    }
    
    public function sendQuery() {
        $data = input('post.');
        $data['merchant_id'] =  $this->C('merchantId');
        $data['signature'] = apiChangyuanSign($data, $this->C('md5key'));  // 创建签名
        $result = Utils::curl($this->C('daifuQueryUrl'), $data);
        return $result;
    }
}
